//package cn.stylefeng.guns.utils;
//
//import com.fasterxml.jackson.annotation.JsonInclude;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.support.ConversionServiceFactoryBean;
//import org.springframework.core.convert.ConversionService;
//import org.springframework.core.convert.converter.Converter;
//import org.springframework.http.MediaType;
//import org.springframework.http.converter.HttpMessageConverter;
//import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
//import org.springframework.util.AntPathMatcher;
//import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//import java.util.ArrayList;
//import java.util.HashSet;
//import java.util.List;
//import java.util.Set;
//
//@Configuration
//public class WebMvcConfig implements WebMvcConfigurer {
//
////从此不再纠结用@DateTimeFormat(patten = "yyyyy-MM-dd")还是@DateTimeFormat(patten = "yyyyy-MM-dd HH：mm") ,告别烦恼，从全局时间转换器开始！！

//    /**
//     * 重写url路径匹配(忽略大小写敏感)
//     */
//    @Override
//    public void configurePathMatch(PathMatchConfigurer configurer) {
//        AntPathMatcher antPathMatcher = new AntPathMatcher();
//        antPathMatcher.setCaseSensitive(false);
//    }
//
//    /**
//     * JSON全局日期转换器
//     */
//    @Bean
//    public MappingJackson2HttpMessageConverter getMappingJackson2HttpMessageConverter() {
//        MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
//        //设置日期格式
//        ObjectMapper objectMapper = new ObjectMapper();
//        objectMapper.setDateFormat(CustomDateFormat.instance);
//        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
//        mappingJackson2HttpMessageConverter.setObjectMapper(objectMapper);
//        //设置中文编码格式
//        List<MediaType> list = new ArrayList<MediaType>();
//        list.add(MediaType.APPLICATION_JSON_UTF8);
//        mappingJackson2HttpMessageConverter.setSupportedMediaTypes(list);
//        return mappingJackson2HttpMessageConverter;
//    }
//
//    @Override
//    public void configureMessageConverters(List<HttpMessageConverter<?>> converters){
//        converters.add(getMappingJackson2HttpMessageConverter());
//    }
//
//    /**
//     * 表单全局日期转换器
//     */
//    @Bean
//    @Autowired
//    public ConversionService getConversionService(DateConverter dateConverter){
//        ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
//        Set<Converter> converters = new HashSet<>();
//        converters.add(dateConverter);
//        factoryBean.setConverters(converters);
//        return factoryBean.getObject();
//    }
//}